/*
 * Copyright (c) 2019 Mike Penz
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mikepenz.iconics.internal;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;
import ohos.app.Context;

import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.animation.BlinkAlphaProcessor;
import com.mikepenz.iconics.animation.BlinkScaleProcessor;
import com.mikepenz.iconics.animation.IconicsAnimatedDrawable;
import com.mikepenz.iconics.animation.SpinProcessor;

/**
 * 解析xml的属性配置
 *
 * @author pa.gulko zTrap
 * @since 2017-07-07
 */
public class IconicsViewsAttrsApplier {
    private static final String SPIN = "spin";
    private static final String BLINK_ALPHA = "blink_alpha";
    private static final String BLINK_SCALE = "blink_scale";

    /**
     * 构造器
     */
    private IconicsViewsAttrsApplier() {
    }

    /**
     * 获取Image图标Drawable
     *
     * @param component 组件
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsImageViewDrawable(Component component, Context context, AttrSet attrSet) {
        IconicsDrawable icon = new IconicsDrawable(component, context);
        if (attrSet.getAttr("iiv_animations").isPresent()) {
            icon = new IconicsAnimatedDrawable(component, context);
            String hasAnimations = attrSet.getAttr("iiv_animations").get().getStringValue();
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_icon").isPresent()) {
            String iconFont = attrSet.getAttr("iiv_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        getIconicsImageViewDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsImageViewDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_corner_radius").get().getDimensionValue();
            icon.setRoundCornerSize(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_automirror").isPresent()) {
            boolean iconAutoMirror = attrSet.getAttr("iiv_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(iconAutoMirror);
        }
    }

    /**
     * 获取Text图标Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_all_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_all_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_all_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_all_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_all_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_all_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_all_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_all_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_all_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_all_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        getIconicsTextDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_all_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_all_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_all_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_all_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_all_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_all_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_all_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_all_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_all_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_all_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_all_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_all_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_all_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_all_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_all_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_all_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_all_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_all_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_all_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_all_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_all_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_all_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取TextChecked的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_all_checked_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_all_checked_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_all_checked_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_all_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_all_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_all_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_all_checked_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_all_checked_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_all_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_all_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        getIconicsTextCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_all_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_all_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_all_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_all_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_all_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_all_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_all_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_all_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_all_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_all_checked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_all_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_all_checked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_all_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_all_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_all_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_all_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_all_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_all_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_all_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_all_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_all_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_all_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text起点的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextStartDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_start_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_start_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_start_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_start_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_start_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_start_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_start_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_start_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        getIconicsTextStartDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextStartDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_start_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_start_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_start_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_start_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_start_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_start_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_start_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_start_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_start_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_start_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_start_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_start_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_start_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_start_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_start_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_start_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_start_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_start_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_start_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_start_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_start_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_start_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_start_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_start_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text起点的选中Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextStartCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_start_checked_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_start_checked_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_start_checked_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_start_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_start_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_start_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_start_checked_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_start_checked_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_start_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_start_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        getIconicsTextStartCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextStartCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_start_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_start_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_start_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_start_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_start_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_start_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_start_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_start_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_start_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_start_checked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_start_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_start_checked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_start_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_start_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_start_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_start_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_start_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_start_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_start_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_start_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_start_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_start_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text顶部的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextTopDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_top_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_top_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_top_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_top_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_top_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_top_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_top_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_top_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_top_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_top_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_top_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_top_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        getIconicsTextTopDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextTopDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_top_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_top_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_top_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_top_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_top_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_top_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_top_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_top_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_top_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_top_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_top_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_top_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_top_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_top_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_top_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_top_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_top_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_top_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_top_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_top_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text顶部的选中Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextTopCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_top_checked_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_top_checked_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_top_checked_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_top_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_top_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_top_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_top_checked_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_top_checked_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_top_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_top_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        getIconicsTextTopCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextTopCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_top_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_top_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_top_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_top_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_top_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_top_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_top_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_top_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_top_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_top_checked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_top_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_top_checked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_top_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_top_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_top_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_top_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_top_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_top_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_top_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_top_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_top_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_top_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text结束处Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextEndDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_end_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_end_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_end_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_end_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_end_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_end_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_end_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_end_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        getIconicsTextEndDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextEndDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_end_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_end_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_end_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_end_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_end_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_end_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_end_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_end_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_end_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_end_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_end_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_end_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_end_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_end_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_end_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_end_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_end_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_end_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_end_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_end_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_end_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_end_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_end_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_end_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text结束处的选中Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextEndCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_end_checked_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_end_checked_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_end_checked_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_end_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_end_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_end_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_end_checked_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_end_checked_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_end_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_end_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        getIconicsTextEndCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextEndCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_end_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_end_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_end_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_end_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_end_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_end_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_end_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_end_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_end_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_end_checked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_end_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_end_checked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_end_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_end_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_end_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_end_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_end_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_end_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_end_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_end_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_end_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_end_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text底部的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextBottomDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_bottom_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_bottom_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_bottom_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_bottom_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_bottom_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_bottom_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_bottom_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_bottom_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_bottom_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_bottom_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_bottom_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_bottom_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        getIconicsTextBottomDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextBottomDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_bottom_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_bottom_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_bottom_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_bottom_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_bottom_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_bottom_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_bottom_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_bottom_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_bottom_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_bottom_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_bottom_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_bottom_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_bottom_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_bottom_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_bottom_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_bottom_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_bottom_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_bottom_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_bottom_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_bottom_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取Text底部的选中Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsTextBottomCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = null;
        if (attrSet.getAttr("iiv_bottom_checked_animations").isPresent()) {
            String hasAnimations = attrSet.getAttr("iiv_bottom_checked_animations").get().getStringValue();
            icon = new IconicsAnimatedDrawable(null, context);
            if (hasAnimations.contains(SPIN)) {
                SpinProcessor spinProcessor = new SpinProcessor();
                ((IconicsAnimatedDrawable) icon).processor(spinProcessor);
            }
            if (hasAnimations.contains(BLINK_ALPHA)) {
                BlinkAlphaProcessor blinkAlphaProcessor = new BlinkAlphaProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkAlphaProcessor);
            }
            if (hasAnimations.contains(BLINK_SCALE)) {
                BlinkScaleProcessor blinkScaleProcessor = new BlinkScaleProcessor();
                ((IconicsAnimatedDrawable) icon).processor(blinkScaleProcessor);
            }
        }
        if (attrSet.getAttr("iiv_bottom_checked_icon").isPresent()) {
            if (icon == null) {
                icon = new IconicsDrawable(null, context);
            }
            String iconFont = attrSet.getAttr("iiv_bottom_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_bottom_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_bottom_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_bottom_checked_size").isPresent()) {
            int iconSize = attrSet.getAttr("iiv_bottom_checked_size").get().getDimensionValue();
            icon.setSize(iconSize);
        }
        if (attrSet.getAttr("iiv_bottom_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_bottom_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_bottom_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_bottom_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        getIconicsTextBottomCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsTextBottomCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_bottom_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_bottom_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_bottom_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_bottom_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_bottom_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_bottom_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_bottom_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_bottom_checked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_bottom_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_bottom_checked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_bottom_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_bottom_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_bottom_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_bottom_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_bottom_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_bottom_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_bottom_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_bottom_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_bottom_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_bottom_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取选中的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = new IconicsDrawable(null, context);
        if (attrSet.getAttr("iiv_checked_icon").isPresent()) {
            String iconFont = attrSet.getAttr("iiv_checked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_checked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_checked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_checked_size").isPresent()) {
            int startSize = attrSet.getAttr("iiv_checked_size").get().getDimensionValue();
            icon.setSize(startSize);
        }
        if (attrSet.getAttr("iiv_checked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_checked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_checked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_checked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_checked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_checked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        getIconicsCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_checked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_checked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        if (attrSet.getAttr("iiv_checked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_checked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_checked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_checked_background_contour_color").get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_checked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_checked_background_contour_width").get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_checked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_checked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_checked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_checked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_checked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_checked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_checked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_checked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_checked_animations").isPresent()) {
            String animations = attrSet.getAttr("iiv_checked_animations").get().getStringValue();
        }
        if (attrSet.getAttr("iiv_checked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_checked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }

    /**
     * 获取未选中的Drawable
     *
     * @param context 上下文
     * @param attrSet 属性
     * @return IconicsDrawable
     */
    public static IconicsDrawable getIconicsUnCheckedDrawable(Context context, AttrSet attrSet) {
        IconicsDrawable icon = new IconicsDrawable(null, context);
        if (attrSet.getAttr("iiv_unchecked_icon").isPresent()) {
            String iconFont = attrSet.getAttr("iiv_unchecked_icon").get().getStringValue();
            icon.setIcon(iconFont);
        }
        if (attrSet.getAttr("iiv_unchecked_color").isPresent()) {
            Color iconColor = attrSet.getAttr("iiv_unchecked_color").get().getColorValue();
            icon.setColor(iconColor);
        }
        if (attrSet.getAttr("iiv_unchecked_size").isPresent()) {
            int startSize = attrSet.getAttr("iiv_unchecked_size").get().getDimensionValue();
            icon.setSize(startSize);
        }
        if (attrSet.getAttr("iiv_unchecked_padding").isPresent()) {
            int iconPadding = attrSet.getAttr("iiv_unchecked_padding").get().getDimensionValue();
            icon.setPaddingPx(iconPadding);
        }
        if (attrSet.getAttr("iiv_unchecked_contour_color").isPresent()) {
            Color iconContourColor = attrSet.getAttr("iiv_unchecked_contour_color").get().getColorValue();
            icon.setContourColor(iconContourColor);
        }
        if (attrSet.getAttr("iiv_unchecked_contour_width").isPresent()) {
            int iconContourWidth = attrSet.getAttr("iiv_unchecked_contour_width").get().getDimensionValue();
            icon.setContourWidthPx(iconContourWidth);
        }
        if (attrSet.getAttr("iiv_unchecked_background_color").isPresent()) {
            Color iconBgColor = attrSet.getAttr("iiv_unchecked_background_color").get().getColorValue();
            icon.setBackgroundColor(iconBgColor);
        }
        getIconicsUnCheckedDrawable2(attrSet, icon);
        return icon;
    }

    private static void getIconicsUnCheckedDrawable2(AttrSet attrSet, IconicsDrawable icon) {
        if (attrSet.getAttr("iiv_unchecked_corner_radius").isPresent()) {
            int iconCornerRadius = attrSet.getAttr("iiv_unchecked_corner_radius").get().getDimensionValue();
            icon.setCornerRadius(iconCornerRadius);
        }
        if (attrSet.getAttr("iiv_unchecked_background_contour_color").isPresent()) {
            Color iconBgContourColor = attrSet.getAttr("iiv_unchecked_background_contour_color")
                .get().getColorValue();
            icon.setBackgroundContourColor(iconBgContourColor);
        }
        if (attrSet.getAttr("iiv_unchecked_background_contour_width").isPresent()) {
            int iconBgContourWidth = attrSet.getAttr("iiv_unchecked_background_contour_width")
                .get().getDimensionValue();
            icon.setBackgroundContourWidthPx(iconBgContourWidth);
        }
        if (attrSet.getAttr("iiv_unchecked_shadow_radius").isPresent()) {
            int iconShadowRadius = attrSet.getAttr("iiv_unchecked_shadow_radius").get().getDimensionValue();
            icon.setShadowRadiusPx(iconShadowRadius);
        }
        if (attrSet.getAttr("iiv_unchecked_shadow_dx").isPresent()) {
            int iconShadowDx = attrSet.getAttr("iiv_unchecked_shadow_dx").get().getDimensionValue();
            icon.setShadowDxPx(iconShadowDx);
        }
        if (attrSet.getAttr("iiv_unchecked_shadow_dy").isPresent()) {
            int iconShadowDy = attrSet.getAttr("iiv_unchecked_shadow_dy").get().getDimensionValue();
            icon.setShadowDyPx(iconShadowDy);
        }
        if (attrSet.getAttr("iiv_unchecked_shadow_color").isPresent()) {
            Color iconShadowColor = attrSet.getAttr("iiv_unchecked_shadow_color").get().getColorValue();
            icon.setShadowColorInt(iconShadowColor);
        }
        if (attrSet.getAttr("iiv_unchecked_animations").isPresent()) {
            String animations = attrSet.getAttr("iiv_unchecked_animations").get().getStringValue();
        }
        if (attrSet.getAttr("iiv_unchecked_automirror").isPresent()) {
            boolean isAutoMirror = attrSet.getAttr("iiv_unchecked_automirror").get().getBoolValue();
            icon.setAutoMirroredCompat(isAutoMirror);
        }
    }
}
